Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

317
Views
Why is onClick={() => this.handleClick()} not recommended in React.js?

According to the React.js documentation, the expression:

onClick={() => this.handleClick()}

is not recommended:

In most cases, this is fine. However, if this callback is passed as a prop to lower components, those components might do an extra re-rendering.

But in what cases and why does it happen? Can anybody explain or give an example?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

if you use this call back only on a plain html tag i think it should be fine. but problem is where you pass this type of callbacks as a prop to a child component. if your top level component happen to rerender and you don't want to child component rerender, if use memo on child component, it rerender anyway because when top level component rerender that callback recreated and each time you check for prev and next prop of child component it is new every time.

================== TopComponent  (props) ============

+------- Child Component - (onClick={()=> console.log('rerendered every time')}) --+
|         memo check funciton ===>(prev,next) => prev===next                       |                               
+----------------------------------------------------------------------------------+


===============================
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!